package com.fdb.efp.esb.service.impl.hj;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.fdb.efp.esb.service.bo.req.hj.ReqBorrowingMoreBean;
import com.fdb.efp.esb.service.bo.resp.hj.RespBorrowingMoreBean;
import com.fdb.efp.esb.service.client.ESBClientFactory;
import com.fdb.efp.esb.service.client.impl.LhxESBBeanCreator;
import com.fdb.efp.esb.service.facade.hj.BorrowingMoreService;

/**
 * 
 * 多借多贷接口
 * 
 * @author liyakui
 * @since 2019年1月4日 下午2:14:11
 * @version 1.0
 */
@Service("borrowingMoreService")
public class BorrowingMoreServiceImpl implements BorrowingMoreService {

	@Override
	public RespBorrowingMoreBean borrowingMore(ReqBorrowingMoreBean reqBorrowingMoreBean) throws Exception {
		Logger logger = LoggerFactory.getLogger(BorrowingMoreServiceImpl.class);
		// 返回对象
		RespBorrowingMoreBean respBorrowingMoreBean = null;
		logger.info("前置流水号：" + reqBorrowingMoreBean.getPrevFlowNo() + "多借多贷款接口开始");
		try {
			// 1.调用ESB客户端服务
			respBorrowingMoreBean = ESBClientFactory.buildClient().withBody(reqBorrowingMoreBean).withTradeNo("30410002").withScene("02")
					.withESBBeanFactory(LhxESBBeanCreator.getINSTANCE()).create().sendAndReceive().getBody(RespBorrowingMoreBean.class);
			if ("0000".equals(respBorrowingMoreBean.getWrongCd())) {
				logger.info("多借多贷接口返回成功！请求参数：" + reqBorrowingMoreBean + "***********返回结果:" + respBorrowingMoreBean);
			} else {
				logger.info("多借多贷接口调用失败！返回结果：" + respBorrowingMoreBean);
			}
		} catch (Exception e) {
			logger.info("调用多借多贷款接口失败！" + e.getMessage());
			throw e;
		}

		return respBorrowingMoreBean;

	}

}
